﻿using csharp_Movies_315.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace csharp_Movies_315.Controllers
{
    public class MovieController : Controller
    {
        // GET: Movie
        public ActionResult Index()
        {
            MovieIndexVm iVm = new MovieIndexVm(); // create the VM
            iVm.Greeting = "guten tag"; //"good day" in german
            iVm.Movies = MovieData.AllMovies; // gets the movie list from static class
            return View(iVm);
        }

        /// Show the detials
        public ActionResult Details(int id)
        {
            // create vm
            MovieDetailsVm dVm = new MovieDetailsVm();
            
            // populate vm w/Movie
            var filtered = MovieData.AllMovies.Where(m => m.MovieId == id).FirstOrDefault();
            dVm.TheMovie = filtered; 
           
            // send to view...
            return View(dVm);
        }
    }
}